package net.zisen.cloud.order.user.ctrl;

import net.zisen.cloud.base.msg.ResultMsg;
import net.zisen.cloud.ping.user.client.UserServiceClient;
import net.zisen.cloud.ping.user.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.Date;
import java.util.UUID;

/**
 * @author tim/278002989@qq.com
 * @Classname UserCtrl
 * @Description TODO
 * @Date 2019-05-16 15:23
 */
@RestController(value = "register/user")
public class UserCtrl {

    @Autowired
    private UserServiceClient userServiceClient;

    @GetMapping("{id}")
    public User getUser(@PathVariable Long id) {

        return null;

    }

    @PostMapping
    public ResultMsg registerUser(@RequestBody User user) {
        user = User.builder().updateTime(new Timestamp(System.currentTimeMillis())).name(UUID.randomUUID().toString()).createTime(new Date()).build();
        return this.userServiceClient.registerUser(user);
    }

}
